using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;

namespace BUS
{
    public class tbNhanvienBUS
    {
        public static void Insert(tbNhanvien nv)
        {
            tbNhanvienDAL nvDAL = new tbNhanvienDAL();
            nvDAL.Insert(nv);
        }
        public static void Update(tbNhanvien nv)
        {
            tbNhanvienDAL nvDAL = new tbNhanvienDAL();
            nvDAL.Update(nv);
        }
        public static void Delete(int iD)
        {
            tbNhanvienDAL nvDAL = new tbNhanvienDAL();
            nvDAL.Delete(iD);
        }
        public static tbNhanvienCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbNhanvienDAL nvDAL = new tbNhanvienDAL();
            return nvDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbNhanvienCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbNhanvienDAL nvDAL = new tbNhanvienDAL();
            return nvDAL.Get(cri.Criter, 0, 0, tbNhanvienColumn.Manv.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbNhanvien GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbNhanvienColumn.Manv.ToString(), Condition.EQUAL, iD);
            tbNhanvienDAL nvDAL = new tbNhanvienDAL();
            tbNhanvienCollection tbnhanvienCollection = nvDAL.Get(cri.Criter, 0, 0, tbNhanvienColumn.Manv.ToString(), OrderDirection.ASC.ToString(), out total);
            if (tbnhanvienCollection.Count > 0)
                return tbnhanvienCollection[0];
            return null;
        }
        public static tbNhanvienCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbNhanvienDAL nvDAL = new tbNhanvienDAL();
            return nvDAL.Get(cri.Criter, 1, number,
             tbNhanvienColumn.Manv.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbNhanvienCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
           tbNhanvienDAL nvDAL = new tbNhanvienDAL();
            return nvDAL.Get(cri.Criter, 1, number,
               tbNhanvienColumn.Manv.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
